package tomoto.util;

/**
 * Utility for basic object operation.
 * 
 * @author Tomoto Shimizu Washio
 * 
 */
public class ObjectUtil {
	@Deprecated
	private ObjectUtil() {}

	/**
	 * Indicates whether two objects are equal. Unlike normal
	 * {@link Object#equals(Object)} invocation i.e. <code>o1.equals(o2)</code>,
	 * this method allows either object to be null.
	 * 
	 * @param o1 object to compare or null.
	 * @param o2 object to compare or null.
	 * @return true if two objects are equals or both are null.
	 */
	public static boolean equals(Object o1, Object o2) {
		if (o1 == null) {
			return o2 == null;
		} else {
			return o1.equals(o2);
		}
	}

	/**
	 * Returns a hash code of an object. Unlike normal {@link Object#hashCode()}
	 * invocation i.e. <code>o1.hashCode()</code>, this method allows the object
	 * to be null and returns zero in such a case.
	 * 
	 * @param o object to get a hash code or null.
	 * @return a hash code of the object or zero if o is null.
	 */
	public static int hashCode(Object o) {
		return o == null ? 0 : o.hashCode();
	}
	
}
